#pragma once
#include <osg/Vec4>
#include <vector>
#include <cyber/Export.h>
#include <amk3/BaseScene.h>
#include <osg/Array>
#include <QString>

struct CB_API HLine{
public:
	float lon0;
	float lat0;
	float lon1;
	float lat1;
	osg::Vec4 color;
	int id{0};
	int type{ 0 };
	int webtype{ 0 };
	int getWebType();
	QString src_city;
	QString dest_city;
};

class HightlightLineSceneContext;
class CB_API HLineImp{
public:
	HLine line;
	osg::ref_ptr<osg::Vec3Array> points;
	HightlightLineSceneContext* context{ 0 };
};

typedef std::vector<HLine> HLineList;
typedef std::vector<HLineImp> HLineImpList;

struct CB_API HightlightLineSceneContext
{
	HLineImpList lines;
	int _checktype{ -1 };
	QString _city;
	int checkRule(HLineImp* hi);
};

class HightlightLineGeometry : public osg::Geometry
{
public:
	void setSegments(int segs);
	void setHLine(HLineImp* line);
	int _segments{0};
	int _index{0};
	int _count{ 0 };
	int _step{ 0 };
	osg::Vec4 _color;
	double _simuTime{0};
	bool _render{ true };
	bool _visible{ false };
	HLineImp* _line{ 0 };
	std::vector<osg::ref_ptr<osg::Geometry>> _circles;
	int _framesUnVisible{ 0 };
	virtual void drawImplementation(osg::RenderInfo& renderInfo) const override;

	void buildCircles(const osg::EllipsoidModel* em);
public:
	class HightlightLineGeometryCallback : public osg::Drawable::UpdateCallback
	{
	public:
		virtual void update(osg::NodeVisitor*, osg::Drawable*);
	};
};

class CB_API HightlightLineScene : public BaseScene
{
public:
	HightlightLineScene();
	~HightlightLineScene();

	void addLine(HLine& hl);

	virtual bool loadData();

	virtual osg::Node* createNode() override;

	void setType(int);

	void setCity(QString s,int i=0);

protected:
	HightlightLineSceneContext context;
	void _buildLines();
};

